package com.qpx.eurekajpa.dao;

import com.qpx.eurekajpa.entity.UserEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface UserDao extends JpaRepository<UserEntity,Integer> {

     UserEntity findByUsernameAndPassword(String username,String password);

     Page<UserEntity> findByNameLike(String name, Pageable pageable);

    @Query(value = "select u from UserEntity u where u.createTime >=:beginTime and u.createTime <= :endTime")
     List<UserEntity> findByCreateTime(@Param("beginTime") Date beginTime, @Param("endTime") Date endTime);


    Page<UserEntity> findAll(Specification<UserEntity> specification,Pageable pageable);
}
